<template>
  <view class="panel">
    <no-data :showErrorTip="showNoData"></no-data>
    <view  v-if="showNoData == false">
      <view class="panel-body" v-for="(item, index) in practiceList.list" :key="index">
        <view class="panel-body-item" @click="linkTo(item.todoId)">
          <view class="todo-item">
            <text class="title">{{item.todoTitle}}</text>
            <text class="context">{{item.todotext}}</text>
          </view>
          <view class="item-time">{{item.todoTime}}</view>
        </view>
      </view>
    </view>
   
  </view>
</template>

<script>
import baseService from "@/services/study/index.js";
const service = new baseService();
export default {
  data() {
    return {
      practiceList: {
        list: []
      },
      showNoData: false
    };
  },
  onReady() {
    this.loadData();
  },
  methods: {
    loadData() {
      service.queryStudyTaskType().then(res => {
        if (res.success) {
          this.practiceList.list = res.result;
        }else{
			uni.showToast({
				title:res.message,
				duration:2000,
				icon:'none'
			});
			this.showNoData = true;
		}
      });
    },

    linkTo(todoId) {
		if('2'==todoId){
			//任务只有公安
			uni.navigateTo({
				url:'/pages/tabbar/study/practice/simulation?ascription=3&from=task'
			})
		}else{
			uni.navigateTo({
			  url: "/pages/tabbar/study/practice/index?type=" + todoId
			});
		}
    }
  }
};
</script>

<style lang="scss">
page {
  background-color: #f1f1f1;
}
.containerin {
  background-color: #fff;
  padding: 20upx 20upx 0;
}
.panel {
  background: #fff;
  padding: 0 10upx;
  &-body {
    width: 100%;
    margin: 0 auto;
    border-bottom: 1px solid #d8d8d8;
    &-item {
      text-align: left;
      overflow: hidden;
      padding: 20upx 0;
      .item-time {
        font-family: SimSun-ExtB;
        font-size: 28upx;
        color: #dedede;
        padding-top: 16upx;
        padding-left: 16upx;
      }

      .title {
        font-size: 24upx;
        color: #ffffff;
        width: 150upx;
        height: 42upx;
        line-height: 42upx;
        background-color: #f1685d;
        border-radius: 30upx;
        text-align: center;
        margin-right: 10upx;
        display: inline-block;
      }

      .context {
        font-size: 30upx;
        color: #333333;
        float: none;
        margin-top: 5px;
        vertical-align: middle;
      }
    }
  }
  &-body:last-child {
    border-bottom: 0;
  }
}
</style>
